package com.xs.designpattern;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author xs
 */
@Slf4j
public class LambdaStrategy {
    /**
     * 枚举来演示策略模式
     */
    @RequiredArgsConstructor
    public enum Strategy implements DragonSlayingStrategy {
        /**
         * 屠龙方法枚举
         */
        MELEESTRATEGY(() -> log.info("你用你的神剑砍下了龙的头!")),
        PROJECTILESTRATEGY(() -> log.info("你用魔法十字弓射杀龙，它倒在地上死了!")),
        SPELLSTRATEGY(() -> log.info("你施展了分解咒语，巨龙就蒸发成了一堆灰尘!"));

        private final DragonSlayingStrategy dragonSlayingStrategy;

        @Override
        public void execute() {
            dragonSlayingStrategy.execute();
        }
    }
}
